/**
 * 2011-11-17下午6:34:25
 */
package dao;

import java.sql.ResultSet;
import java.sql.SQLException;

import util.MysqlConn;
import bean.Userinfo;

/**
 * @author Baicai 根据num获得一个userinfo信息
 */
public class SelectOneUserinfo {
	public static Userinfo getUserinfo(String string) {

		try {

			Userinfo userinfo = new Userinfo();
			MysqlConn
					.setSqlString("select * from userinfo where userinfo_num='"
							+ string + "'");// 设置sql语句
			ResultSet resultSet = MysqlConn.queryDB();// 执行，或取结果集
			resultSet.next();
			userinfo.setUserinfoId(resultSet.getInt("userinfo_id"));
			userinfo.setUserinfoName(resultSet.getString("userinfo_name"));
			userinfo.setUserinfoNum(resultSet.getString("userinfo_num"));
			userinfo.setUserinfoSex(resultSet.getString("userinfo_sex"));

			return userinfo;

		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			MysqlConn.free();
		}

		return null;
	}
}
